{include file="common/header.tpl"}
<section class="main">	
    <article class="right-col">
    	<h2>{$language.title.permission}</h2>
        {include file="permission/filter.tpl"}
        <form id="frmPermission" name="frmPermission" method="post" action="{$smarty.const.HOST_BACKEND}permission/save" enctype="multipart/form-data">
            <input type="hidden" name="padminid" id="padminid" value="{$info->id}" />
            <input type="hidden" name="pusername" id="pusername" value="{$info->username}" />
            {if $arrAPerm && $AppUI->type >= $smarty.const.ROLE_LEADER}              	
               	<div class="s-button">
                    <button type="button" onclick="javascript:savePermission(this.form)">{$language.btn.save}</button>
                </div>
            {/if}
            <table width="100%" cellpadding="0" cellspacing="0" border="0" class="list">
                <thead>
                    <tr>
                        <th>{$language.label.module}</th>
                        <th width="80%">{$language.label.perm}</th>
                    </tr>
                </thead>
                <tbody>
                	{if !isset($info)}
                    	<tr><td align="center" colspan="2">Vui lòng chọn thành viên mà bạn muốn phân quyền</td></tr>                    {elseif isset($arrAPerm)}
                        {foreach item=item from=$arrAPerm}
                            {if $info->type >= $item.perm_a}
                                <tr class="{cycle values="odd,even"}">
                                    <td><label for="pPerm6_{$item.sectionid}" style="width:100%;">{$item.name}</label></td>
                                    <td>                                                    	
                                        <div class="chkPerm">
                                            <!--check all-->
                                            <input type="checkbox" id="pPerm6_{$item.sectionid}" class="chkPerm" onclick="javascript:checkAllPerm(this,'{$item.sectionid}')" {if $item.perm >-1 && (($item.perm&1<<0)>0) && (($item.perm&1<<1)>0) && (($item.perm&1<<2)>0) && (($item.perm&1<<3)>0) && (($item.perm&1<<4)>0) && (($item.perm&1<<5)>0)}checked="checked"{/if}/>
                                            <label for="pPerm6_{$item.sectionid}" class="chkPerm">{$language.label.chk_all}</label>
                                        </div>
                                        <div class="chkPerm">
                                            <input type="checkbox" name="pPerm{$item.sectionid}[]" id="pPerm0_{$item.sectionid}" value="{pow x=2 y=0}" class="chkPerm" onclick="javascript:uncheckAllPerm(this,'{$item.sectionid}')" {if $item.perm >-1 && ($item.perm&1<<0)>0}checked="checked"{/if}/>
                                            <label for="pPerm0_{$item.sectionid}" class="chkPerm">{$language.label.view}</label>
                                        </div>
                                        <div class="chkPerm">
                                            <!--them moi-->
                                            <input type="checkbox" name="pPerm{$item.sectionid}[]" id="pPerm1_{$item.sectionid}" value="{pow x=2 y=1}" class="chkPerm" onclick="javascript:uncheckAllPerm(this,'{$item.sectionid}')" {if $item.perm >-1 && ($item.perm&1<<1)>0}checked="checked"{/if}/>
                                            <label for="pPerm1_{$item.sectionid}" class="chkPerm">{$language.label.add}</label>
                                        </div>
                                        <div class="chkPerm">
                                            <!--cap nhat-->
                                            <input type="checkbox" name="pPerm{$item.sectionid}[]" id="pPerm2_{$item.sectionid}" value="{pow x=2 y=2}" class="chkPerm" onclick="javascript:uncheckAllPerm(this,'{$item.sectionid}')" {if $item.perm >-1 && ($item.perm&1<<2)>0}checked="checked"{/if}/>
                                            <label for="pPerm2_{$item.sectionid}" class="chkPerm">{$language.label.edit}</label>
                                        </div>
                                        <div class="chkPerm">
                                            <!--xoa-->
                                            <input type="checkbox" name="pPerm{$item.sectionid}[]" id="pPerm3_{$item.sectionid}" value="{pow x=2 y=3}" class="chkPerm" onclick="javascript:uncheckAllPerm(this,'{$item.sectionid}')" {if $item.perm >-1 && ($item.perm&1<<3)>0}checked="checked"{/if}/>
                                            <label for="pPerm3_{$item.sectionid}" class="chkPerm">{$language.label.delete}</label>
                                        </div>
                                        <div class="chkPerm">
                                            <!--tam dung-->
                                            <input type="checkbox" name="pPerm{$item.sectionid}[]" id="pPerm4_{$item.sectionid}" value="{pow x=2 y=4}" class="chkPerm" onclick="javascript:uncheckAllPerm(this,'{$item.sectionid}')" {if $item.perm >-1 && ($item.perm&1<<4)>0}checked="checked"{/if}/>
                                            <label for="pPerm4_{$item.sectionid}" class="chkPerm">{$language.label.suspend}</label>
                                        </div>
                                        <div class="chkPerm">
                                            <!--kich hoat/phuc hoi-->
                                            <input type="checkbox" name="pPerm{$item.sectionid}[]" id="pPerm5_{$item.sectionid}" value="{pow x=2 y=5}" class="chkPerm" onclick="javascript:uncheckAllPerm(this,'{$item.sectionid}')" {if $item.perm >-1 && ($item.perm&1<<5)>0}checked="checked"{/if}/>
                                            <label for="pPerm5_{$item.sectionid}" class="chkPerm">{$language.label.active}</label>
                                        </div>
                                    </td>
                                </tr>
                            {/if}
                        {/foreach}
                   	{/if}
                </tbody>
            </table>
            {if $arrAPerm && $AppUI->type >= $smarty.const.ROLE_LEADER}            	
               	<div class="s-button">
                    <button type="button" onclick="javascript:savePermission(this.form)">{$language.btn.save}</button>
                </div>
            {/if}
        </form>
    </article>
</section>
{include file="common/footer.tpl"}
                
